<? if ($c = stack('name')) {

	$d = component_data($c);

	?><section id="cpn-<?=$c?>" class="cpn-register"><?

			startScript('jquery, jquery.validationEngine, jquery.validationEngine-'.context('lang').', other-validations-'.context('lang').', jquery.maskedinput.min, jquery.tools, jquery.linked_select, jquery.jstree, jquery.autocomplete, jquery.koatuudo, jquery.sbx');

			?><script type="text/javascript">
			//$( "#birthday" ).dateinput({format: 'dd.mm.yyyy', lang: '<?//=context('lang')?>', selectors: true, min: '1900-01-01', max: new Date(), firstDay: 1, yearRange: [-100,1]});
			
			
			
			$("#cpn-<?=$c?> form").validationEngine({
				ajaxFormValidation: true,

				onAjaxFormComplete: function ajaxValidationCallback(status, form, json, options){
					if (status === true) {
						location.href = "/<?=$CONTEXT['lang_prefix']?>my/";
					}
				}
			});

			$("#idcode").masked("9999999999");
			$("#fact_index").masked("99999");

			//$("#birthday").masked("99.99.9999");

			$('#koatuu').koatuudo({});

			</script><? endScript();
		
			?><form action="./" method="post">

				<h1><?=tc('Редагування особистих даних')?></h1>
				<!--<p class="nb">(<?//=gccUserInfo('email')?>)</p>-->
				<p class='nb'><?=tc("Символом <span class='required'>*</span> відмічені поля, обов'язкові для заповнення.")?></p>
				<fieldset>
<? /*					<h2 class="legend"> <?=tc('Personal data')?> </h2>
*/ ?>			
					<div class="inner">
						<label class="col1"><?=tc('Last Name')?><span class="required">*</span>
							<input name="lastname" id="lastname" type="text" class="validate[required,custom[fio_uk]]" value="<?=h(gccUserInfo('lastname'))?>"></label>
						<label class="col1"><?=tc('First name')?><span class="required">*</span>
							<input name="firstname" id="firstname" type="text" class="validate[required,custom[fio_uk]]" value="<?=h(gccUserInfo('firstname'))?>"></label>
						<label class="col1"><?=tc('Middle Name')?><span class="required">*</span>
							<input name="middlename" id="middlename" type="text" class="validate[required,custom[fio_uk]]" value="<?=h(gccUserInfo('middlename'))?>"></label>

						<div class="col1"><?=tc('Gender')?><?
							?><div class="input"><?
							foreach($d['gender_id'] as $id => $v) {
								?><label style="margin-right:15px"><input name="gender" type="radio" <?= gccUserInfo('gender') == $id ? 'checked' : '' ?> value="<?=$id?>"> <?=$v?></label><?
							}
						?></div></div>

						<label class="col1"><?=tc('Birth Year')?>
							<!--<input name="birthday" id="birthday" type="text" class="validate[custom[date],past[NOW],future[1900/01/01]] short" value="<?//=$d['rfc_birthday']?>">-->
								<select name="birthday" id="birthday">
									<option value=""></option>
									<? for ($i = 1904; $i < date("Y"); $i++) {  ?>
										<option <?= substr($d['rfc_birthday'],0,4) == $i ? 'selected' : '' ?> 
													value="01.01.<?=$i?>"><?=$i?></option>
									<? } ?>	
								</select>
							
							</label>

					</div>

					<h2 class="legend"> <?=tc('Contact data')?> </h2>

					<div class="inner">
						<label class="col1"><?=tc('Index')?><span class="required">*</span>
							<input name="fact_index" id="fact_index" type="text" class="validate[required,custom[integer],minSize[5], maxsize[5]] short" value="<?=h(gccUserInfo('fact_index'))?>"></label>

						<label class="col0"><?=tc('Region, district, town')?><span class="required">*</span>
							<input name="fact_geo_id" id="koatuu" type="text" class="validate[required]" value="<?=h(gccUserInfo('fact_geo_id'))?>" data-title="<?=h(gccUserInfo('fact_geo_id_title'))?>"></label>

						<label class="col1"><?=tc('Address')?><span class="required">*</span>
							<input name="fact_address" id="fact_address" type="text" class="validate[required,custom[name_uk]]" value="<?=h(gccUserInfo('fact_address'))?>"></label>


						<div class="row">
							<div class="col1"><?=tc('Контактні телефони')?>
								<input name="contactphone" id="contactphone" class="validate[custom[phone_uk],maxSize[14]]" 
								 		style="width:90px;" type="text" value="<?=h(gccUserInfo('contactphone'))?>" maxlength="14">
								<input name="contactphone2" id="contactphone2" type="text" class="validate[custom[phone_uk],maxSize[14]]" 
										style="width:90px; left:390px;" value="<?=h(gccUserInfo('contactphone2'))?>" maxlength="14">
							</div>
						</div>

					</div>

					<h2 class="legend"> <?=tc('Additional data')?> </h2>

					<div class="inner">
						<label class="col1"><?=tc('Category')?>
						<select name="category_id" id="category_id" value="<?=gccUserInfo('category_id')?>"><?
							?><option value=""><?=tc('Undefined')?></option><?
							foreach($d['category_id'] as $id => $v) {
								?><option <?= gccUserInfo('category_id') == $id ? 'selected' : '' ?> value="<?=$id?>"><?=$v['name']?></option><?
							}
						?></select></label>

						<label class="col1"><?=tc('Social status')?>
						<select name="socialstatus_id" id="socialstatus_id" value="<?=gccUserInfo('socialstatus_id')?>"><?
							?><option value=""><?=tc('Undefined')?></option><?
							foreach($d['socialstatus_id'] as $id => $v) {
								?><option <?= gccUserInfo('socialstatus_id') == $id ? 'selected' : '' ?> value="<?=$id?>"><?=$v['name']?></option><?
							}
						?></select></label>
					</div>
				</fieldset>
				
				<div class="div-right">
					<input type="submit" name="register" value="<?=htc('Save')?>">
					<input type="button" name="back" value="<?=tc('Відмінити')?>" onclick="location.href = '/<?=$CONTEXT['lang_prefix']?>my/'">
				</div>


				
			</form><?

		?><div class="clearer"></div><?
	?></section><?

	unstack();
}
